package net.xgclass.online_xgclass.utils;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.vod.model.v20170321.GetPlayInfoRequest;
import com.aliyuncs.vod.model.v20170321.GetPlayInfoResponse;

import java.util.List;

/**
 * 上传视频
 * 获取视频播放地址
 */
public class GetPlayUrlUtils {
    public static List<GetPlayInfoResponse.PlayInfo> getPlayUrl(String id) throws Exception{
        //创建初始化对象
        DefaultAcsClient client = InitVodClientUtils.initVodClient(UploadFileImgUtils.ACCESS_KEY_ID, UploadFileImgUtils.ACCESS_KEY_SECRET);

        //创建获取视频地址request和response
        GetPlayInfoRequest request = new GetPlayInfoRequest();
        GetPlayInfoResponse response = new GetPlayInfoResponse();

        //向request对象里面设置视频id
        request.setVideoId(id);

        //调用初始化对象里面的方法，传递request，获取数据

        response = client.getAcsResponse(request);

        List<GetPlayInfoResponse.PlayInfo> playInfoList = response.getPlayInfoList();
        // //播放地址
        // for (GetPlayInfoResponse.PlayInfo playInfo : playInfoList) {
        //     System.out.print("PlayInfo.PlayURL = " + playInfo.getPlayURL() + "\n");
        // }
        // //Base信息
        // System.out.print("VideoBase.Title = " + response.getVideoBase().getTitle() + "\n");

        return playInfoList;
    }
}
